import { camera, scene } from './utils/init'
import * as THREE from 'three'

function initBase() {
  const geometry = new THREE.PlaneGeometry(10, 10)
  const meterial = new THREE.MeshStandardMaterial({color: 0xffffff})
  const plane = new THREE.Mesh(geometry, meterial)
  plane.rotation.set(-Math.PI / 2, 0, 0)
  scene.add(plane)
}

// 创建聚光灯
function createLight () {
  // 聚光灯对象 颜色强度 试着修改颜色看看
  const spotlight = new THREE.SpotLight(0xff00ff, 1)
  spotlight.position.set(3, 3, 3)
  // 图片和聚光灯颜色混合后打到物体上
  spotlight.map = new THREE.TextureLoader().load('image/desert.jpg')
  scene.add(spotlight)
  // 聚光灯辅助对象
  const helper = new THREE.DirectionalLightHelper(spotlight, 1)
  scene.add(helper)
}
camera.position.set(5, 5, 5)
initBase()
createLight()
